package HeSuanServer.controller;

import HeSuanServer.POJO.R.Result;
import HeSuanServer.POJO.EmpSearch;
import HeSuanServer.POJO.Employee;
import HeSuanServer.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @描述:
 * @author: LH
 * @date: 2022/12/6
 */
@CrossOrigin
@RequestMapping("emp")
@RestController
@Slf4j
public class empController {
    @Autowired
    private EmpService empService;
    @GetMapping("findAll")
    public Result findAll(){
        return empService.findAll();
    }
    @GetMapping("byId")
    public Result getById(Integer id){
        return empService.getById(id);
    }
    @PostMapping("edit")
    public Result editById(@RequestBody Employee emp){return empService.editById(emp);}
    @PostMapping("add")
    public Result add(@RequestBody Employee emp){
        return empService.add(emp);
    }
    @GetMapping("del")
    public Result delEmp(Integer id){
        return empService.del(id);
    }
    @GetMapping("byName")
    public Result name(String name){
        return empService.getByName(name);
    }
    @PostMapping("findEmp")
    public Result findEmp(@RequestBody EmpSearch search){
        return empService.byPage(search);
    }
    @PostMapping("findByPage")
    public Result byPage(@RequestBody EmpSearch search){
        return empService.byPage(search);
    }
}
